<!DOCTYPE html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1,shrink-to-fit=no">
        <title>index</title>
		<style type="text/css">
		input {
                        padding: 2 4 0 4;
                      font-size: 12px;
               background-color: #ece9d8;
              }
		</style>
        <!-- jquery cdn, 可换其他 -->
        <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    </head>
    <body>
	<div class="hah">
        <input id="click" type="button" value="点击" onclick="operate('click')" /><br/>
        <input id="collect" type="button" value="收藏" onclick="operate('job_collect')" /><br/>
        <input id="send" type="button" value="投简历" onclick="operate('cv_send')" /><br/>
        <input id="upload" type="button" value="上传简历" onclick="operate('cv_upload')" /><br/>
    </div>
	</body>

    <script>

        function operate(action) {

            var json = {'user_id': Math.random().toString(36).substr(2), 'act_time': current().toString(), 'action': action, 'job_code': Math.random().toString(36).substr(2)};

            $.ajax({
                url:"http://192.168.159.161:80/kafka/access",
                type:"POST" ,
                crossDomain: true,
                data: JSON.stringify(json),
                // 下面这句话允许跨域的cookie访问
                xhrFields: {
                    withCredentials: true
                },
                success:function (data, status, xhr) {

                    // console.log("操作成功：'" + action)
                },
                error:function (err) {

                    // console.log(err.responseText);
                }
            });
        };

        function current() {
            var d   = new Date(),
                str = '';
            str += d.getFullYear() + '-';
            str += d.getMonth() + 1 + '-';
            str += d.getDate() + ' ';
            str += d.getHours() + ':';
            str += d.getMinutes() + ':';
            str += d.getSeconds();
            return str;
        }
		

    </script>

</html>